package dao

import (
	"writerhelper/global"
	"writerhelper/model"
)

//查找 user
func FindUser(u *model.User) bool {
	var user model.User
	//res := global.MysqlDB.Where("email=?",u.Email).First(&user)
	//if errors.Is(res.Error, gorm.ErrRecordNotFound) {
	//	return false
	//}else {
	//	return true
	//}
	if err := global.MysqlDB.Where("email=?", u.Email).First(&user).Error;err!=nil{
		return false
	}else {
		return true
	}
}



// 注册一个register

func RegisterUser(u *model.User) bool {
	global.MysqlDB.Create(u)
	if u.ID != 0 {
		return true
	}else{
		return false
	}
}